package com.elione.modbus;
import java.util.Arrays;  

public class SignalReadingTest {

	public static void readingTest() throws Exception {
		
		String slaveIP = "192.168.150.19";
		ModbusSlaveInfo slave = new ModbusSlaveInfo(slaveIP); 
		slave.setSocketTimeout(500);
				
		ModbusTcpMaster master = new ModbusTcpMaster(); 
		master.setModbusTcpConnection(slave);
		
		int address = 12289; 
		int size = 30; 
		int type = ModbusSignal.MTYPE_W;		
		ModbusSignal siganl = new ModbusSignal(address, type, size);
		
		
		byte[] res = master.readArrayItemsRawValues(slave, siganl, 1,30);  
		
		System.out.println("Raw = " + Arrays.toString(res));
		
		int[] values = (int[]) DataTypeUtil.convertArrayRawValue(res, 3, false);
				
		System.out.println("result = " + Arrays.toString(values));
		
		System.out.println("Auth_SUCC = " + (values[0] == 0 ? "false": "true"));
		
	}
	
	
	public static void main(String[] args) throws Exception {
		
		SignalReadingTest.readingTest();
		
		

	}

}
